package com.example.designPattern.Prototype;


public class PrototypeTest {
    public static void main(String[] args) {

        try {

            ShallowClone a=new ShallowClone();
            a.setList("2020");
            a.setName("gp16860");

            ShallowClone b=(ShallowClone) a.clone();
            b.setName("pwl");
            b.setList("2019");

            System.out.println("b:"+b.getName()+"-"+b.getList());
            System.out.println("a:"+a.getName()+"-"+a.getList());


            Address address2=new Address(10,"Hunan","Shenz","2018");
            DeepClone a2=new DeepClone("GuPao","3456789",address2);

            System.out.println("a2:"+a2.getName()+"-"+a2.getAddress().getCName());


            a2.setAddress(new Address(12,"jx", "gz","2021"));
            a2.setName("gp16860");


            DeepClone b2=(DeepClone) a2.clone();
            b2.setName("gupao");
            b2.getAddress().setCName("guanz");

            System.out.println("b2:"+b2.getName()+"-"+b2.getAddress().getCName());
            System.out.println("a2:"+a2.getName()+"-"+a2.getAddress().getCName());

        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
    }
}
